//
//  UserModel.h
//  youyue
//
//  Created by oceans on 2018/8/16.
//

#import <Foundation/Foundation.h>
#import <WXApi.h>
#import <TencentOpenAPI/TencentOAuth.h>

typedef NS_ENUM(NSUInteger, ThirdPartyLogin) {
    TPL_WECHAT,
    TPL_QQ,
};

@interface LoginUser : NSObject

@property (copy, nonatomic) NSString *avatar;
/**yyyy-MM-dd*/
@property (copy, nonatomic) NSString *birthday;
@property (assign, nonatomic) int children;
@property (copy, nonatomic) NSString *cover;
/**0未知，1男，2女*/
@property (assign, nonatomic) int gender;
/**教师评级*/
@property (assign, nonatomic) int grade;
@property (strong, nonatomic) NSArray <NSString *> *hobby;
@property (copy, nonatomic, readonly) NSString *hobyString;
@property (assign, nonatomic) int _id;
@property (copy, nonatomic, readonly) NSString *string_id;
@property (copy, nonatomic) NSString *location;
/**默认：0，已婚：1，未婚：2*/
@property (assign, nonatomic) int marriage;
@property (copy, nonatomic) NSString *nation;
@property (copy, nonatomic) NSString *nickname;
@property (copy, nonatomic, readonly) NSString *nameString;
@property (copy, nonatomic) NSString *realname;
@property (copy, nonatomic) NSString *register_time;
/**0普通用户 1校长 2助教 3老师*/
@property (assign, nonatomic) int role_id;
@property (copy, nonatomic) NSString *signature;
@property (strong, nonatomic) NSArray <NSString *> *teach_scopes;
@property (copy, nonatomic, readonly) NSString *scopeString;
/**融云token*/
@property (copy, nonatomic) NSString *rongyun_token;
/**手机号*/
@property (copy, nonatomic) NSString *mobile;

- (instancetype)initWithDic:(NSDictionary *)dic;
@end

typedef void(^LoginSuccessBlock)(void);
typedef void(^LoginFailedBlock)(void);
@interface UserModel : NSObject <WXApiDelegate>

@property (strong, nonatomic) LoginUser *loginUser;
@property (assign, nonatomic) BOOL hasLogin;
/**用户 0，老师 1，校长 3*/
@property (assign, nonatomic) int userType;
+ (instancetype)shared;

- (void)loginWithPassword:(NSString *)password username:(NSString *)username successBlock:(LoginSuccessBlock)successBlock;
- (void)loginWithCode:(NSString *)code username:(NSString *)username successBlock:(LoginSuccessBlock)successBlock;
- (void)loginWithThirdParty:(ThirdPartyLogin)type successBlock:(LoginSuccessBlock)successBlock failedBlock:(LoginFailedBlock)failedBlock;

- (void)getCodeWithPhoneNumber:(NSString *)phone scope:(NSString *)scope successBlock:(LoginSuccessBlock)successBlock failedBlock:(LoginFailedBlock)failedBlock;

- (void)registerWithName:(NSString *)userName code:(NSString *)code password:(NSString *)password successBlock:(LoginSuccessBlock)successBlock;
- (void)findPassword:(NSString *)userName code:(NSString *)code password:(NSString *)password successBlock:(LoginSuccessBlock)successBlock;
- (void)bindingNewPhone:(NSString *)phone code:(NSString *)code successBlock:(LoginSuccessBlock)successBlock;
- (void)resetPassword:(NSString *)password successBlock:(LoginSuccessBlock)successBlock;

- (void)thirdPartyBindPhone:(NSString *)phone code:(NSString *)code connect_id:(NSString*)connect_id successBlock:(LoginSuccessBlock)successBlock;

- (void)updateUserinfo:(NSString *)infoName value:(id)value successBlock:(LoginSuccessBlock)successBlock;

- (void)rongyunLogin;
- (void)loginWithDic:(NSDictionary *)userInfo;
- (void)clearWhenLogout;
- (void)logoutWith401;
- (void)logoutSuccessBlock:(LoginSuccessBlock)successBlock;
@end
